package com.mallcai.bigdata.ladon.service.common;

import com.alicp.jetcache.anno.Cached;
import com.mallcai.bigdata.ladon.dpl.entity.common.CommonInfo;
import com.mallcai.bigdata.ladon.dpl.entity.common.Datasource;
import com.mallcai.bigdata.ladon.service.report.impl.ReportQueryConstants;
import com.mallcai.bigdata.ladon.vo.*;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * Created by oneape<oneape15@163.com>
 * Created 2019-05-27 17:11.
 * Modify:
 */
public interface ICommonInfoService {

    public static final String CACHE_GET_BY_CLASSIFY = "ICommonInfoService.getByClassify-";

    /**
     * 添加
     *
     * @param ci CommonInfo
     * @return int 1 - 成功; 0 - 失败;
     */
    int add(CommonInfo ci);

    /**
     * 批量添加
     *
     * @param dataList
     * @return int 1 - 成功; 0 - 失败;
     */
    int batchAdd(List<CommonInfo> dataList);

    /**
     * 修改
     *
     * @param ci CommonInfo
     * @return int 1 - 成功; 0 - 失败;
     */
    int edit(CommonInfo ci);

    /**
     * 删除
     *
     * @param ci CommonInfo
     * @return int 1 - 成功; 0 - 失败;
     */
    int delete(CommonInfo ci);

    /**
     * 根据条件查询
     *
     * @param params Map
     * @return List
     */
    List<CommonInfo> getByParams(Map<String, Object> params);

    /**
     * 根据Id查询数据源
     *
     * @param id Long 数据id
     * @return Datasource
     */
    CommonInfo getById(Long id);

    /**
     * 根据类型获取
     *
     * @param classify String
     * @return List
     */
    @Cached(name = CACHE_GET_BY_CLASSIFY, key = "args[0]",
            expire = 1, timeUnit = TimeUnit.HOURS)
    List<CommonInfo> getByClassify(String classify);
}
